<script>
import {createProps} from '@/utils';
import {Button} from 'ant-design-vue';

export default {
  name: 'BaseButton',
  props: {
    disabled: createProps(Boolean, false),
    config: createProps(Object, () => ({}))
  },
  render(h) {
    return h(Button, {
      props: {
        disabled: this.disabled,
        type: this.config.buttonType,
        shape: this.config.buttonShape
      },
      on: {
        click: () => this.$emit('click')
      },
      style: {
      }
    }, [
      this.config && this.config.icon && this.createIcon() || undefined,
      this.createLabel()
    ]);
  },
  methods: {
    createLabel() {
      return this.$createElement('span', [this.config.showName || this.config.buttonName])
    },
    createIcon() {
      return this.$createElement('span', {
        class: ['iconfont', 'anticon'],
        domProps: {
          innerHTML: `&#x${this.config.icon};`
        }
      });
    }
  }
};
</script>